package com.uu.safeguard.service.impl;

import com.uu.safeguard.entity.ChargeLog;
import com.uu.safeguard.dao.ChargeLogDao;
import com.uu.safeguard.service.ChargeLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.LinkedHashMap;
import java.util.List;

/**
 * (ChargeLog)表服务实现类
 *
 * @author makejava
 * @since 2021-07-06 14:08:13
 */
@Service("chargeLogService")
public class ChargeLogServiceImpl implements ChargeLogService {
    @Resource
    private ChargeLogDao chargeLogDao;
    /**
     * @Description: 某运营商某天设备充电记录
     * @Param: [operatorMemberSn, stationSn, startIndex, endIndex, startTime, endTime]
     **/
    @Override
    public List<LinkedHashMap<String, Object>> findStationConsumeDayLog(String operatorMemberSn, String stationSn, int pageIndex, int pageSize, Long startTime, Long endTime) {
        return chargeLogDao.findStationConsumeDayLog(operatorMemberSn,stationSn,(pageIndex-1)*pageSize,pageSize,startTime,endTime);
    }

    @Override
    public LinkedHashMap<String, Object> findStationConsumeDayLogCount(String stationSn, String operatorMemberSn, Long startTime, Long endTime) {
        return chargeLogDao.findStationConsumeDayLogCount(operatorMemberSn,stationSn,startTime,endTime);
    }

    /**
     * @Description: 某月设备每天 充电记录
     * @Param: [stationSn, operatorMemberSn, startTime, endTime]
     **/
    @Override
    public List<LinkedHashMap<String, Object>> findStationConsumeList(String stationSn, String operatorMemberSn, Long startTime, Long endTime) {
        return chargeLogDao.findStationConsumeList(stationSn,operatorMemberSn,startTime,endTime);
    }

    @Override
    public LinkedHashMap<String, Object> findStationConsumeListTotal(String stationSn, String operatorMemberSn, Long startTime, Long endTime) {
        return chargeLogDao.findStationConsumeListTotal(stationSn,operatorMemberSn,startTime,endTime);
    }

    /**
     * @Description: 消费柱状图
     * @Param: [operatorMemberSn, projectSn]
     **/
    @Override
    public LinkedHashMap<String, Object> findConsumeHistogram(String operatorMemberSn, String projectSn) {
        return chargeLogDao.findConsumeHistogram(operatorMemberSn,projectSn);
    }

    /**
     * @Description: 年月日 用户充电利润列表
     * @Param: [operatorMemberSn, projectSn, stationSn, memberSn, pageIndex, pageSize, startTime, endTime]
     **/
    @Override
    public List<LinkedHashMap<String, Object>> findMemberConsumeListByTime(String operatorMemberSn, String projectSn, String stationSn, String memberSn, int pageIndex, int pageSize, Long startTime, Long endTime) {
        return chargeLogDao.findMemberConsumeListByTime(operatorMemberSn,projectSn,stationSn,memberSn,(pageIndex-1)*pageSize,pageSize,startTime,endTime);
    }

    @Override
    public LinkedHashMap<String,Object> findMemberConsumeListByTimeCount(String operatorMemberSn, String projectSn, String stationSn, String memberSn, Long startTime, Long endTime) {
        return chargeLogDao.findMemberConsumeListByTimeCount(operatorMemberSn,projectSn,stationSn,memberSn,startTime,endTime);
    }

    /**
     * @Description: 用户充电列表
     * @Param: [sn, operatorMemberSn, startIndex, endIndex]
     **/
    @Override
    public List<LinkedHashMap<String, Object>> findMemberChargeList(String sn, String operatorMemberSn, int pageIndex, int pageSize) {
        return chargeLogDao.findMemberChargeList(sn,operatorMemberSn,(pageIndex-1)*pageSize,pageSize);
    }

    @Override
    public Integer findMemberChargeListCount(String sn, String operatorMemberSn) {
        return chargeLogDao.findMemberChargeListCount(sn,operatorMemberSn);
    }

    /**
     * @Description: 正在充电列表
     * @Param: [memberSn]
     **/
    @Override
    public List<LinkedHashMap<String, Object>> searchMemberChargeList(String memberSn) {
        return chargeLogDao.searchMemberChargeList(memberSn);
    }

    /**
     * @Description: 充电记录
     * @Param: [memberSn]
     **/
    @Override
    public List<LinkedHashMap<String, Object>> searchMemberChargeLog(String memberSn) {
        return chargeLogDao.searchMemberChargeLog(memberSn);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ChargeLog queryById(Integer id) {
        return this.chargeLogDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<ChargeLog> queryAllByLimit(int offset, int limit) {
        return this.chargeLogDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param chargeLog 实例对象
     * @return 实例对象
     */
    @Override
    public ChargeLog insert(ChargeLog chargeLog) {
        this.chargeLogDao.insert(chargeLog);
        return chargeLog;
    }

    /**
     * 修改数据
     *
     * @param chargeLog 实例对象
     * @return 实例对象
     */
    @Override
    public ChargeLog update(ChargeLog chargeLog) {
        this.chargeLogDao.update(chargeLog);
        return this.queryById(chargeLog.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.chargeLogDao.deleteById(id) > 0;
    }
}